﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DeSleeper.Library
{
    /// <summary>
    /// Settings for logging on to Live Mesh cloud services.
    /// </summary>
    [Serializable]
    public class CloudSettings : IEquatable<CloudSettings>
    {
        /// <summary>
        /// Mesh URI.  i.e. https://user-ctp.windows.net/
        /// </summary>
        public string Uri { get; set; }

        /// <summary>
        /// Live ID to use to login to Live Mesh.  If null, and possible, will prompt, or take from environment.
        /// </summary>
        public string UserID { get; set; }

        // TODO: Should find a way to make sure this is encrypted or taken from a secure location.
        /// <summary>
        /// Password to use to login to Live Mesh.    If null, and possible, will prompt, or take from environment.
        /// </summary>
        public string Password { get; set; }

        public bool Equals(CloudSettings obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            return Equals(obj.Uri, Uri) && Equals(obj.UserID, UserID) && Equals(obj.Password, Password);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (CloudSettings)) return false;
            return Equals((CloudSettings) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = Uri.GetHashCode();
                result = (result*397) ^ UserID.GetHashCode();
                result = (result*397) ^ Password.GetHashCode();
                return result;
            }
        }
    }
}